<template>
	<view>
		<view :class="order_info.ticketCode ?'movie' : 'movieClose'">
			<view class="movie_del" @click="order_del">
				<uni-icons type="trash-filled" size="30"></uni-icons>
			</view>
			<view class="movie_status" v-if="order_info.status">
				<view class="movie_status_bor">
					<text>{{order_info.status | status }}</text>
				</view>
			</view>
			<view class="movie_info">
				<img class="movie_info_pic" :src="order_info.filmPic" />
				<view class="movie_info_text">
					<view class="movie_info_text_name">{{order_info.filmName || '电影名称'}}</view>
					<view class="movie_info_text_address">影院:{{order_info.cinemaName || '影院名称'}}</view>
					<view class="movie_info_text_room">影厅:{{order_info.hallName || '影厅名称'}}</view>
					<view class="movie_info_text_type">座位号:{{order_info.seat || '座位号'}}</view>
					<view class="movie_info_text_time">下单日期:{{order_info.create_time|formatTime}}</view>
				</view>
			</view>
			<view class="movie_line"></view>
			<view class="movie_notice">
				<image class="movie_notice_img" v-for="(item, index) in order_info.ticketImage" :key="index" :src="item"
					@click="previewImg(item)"></image>
				<view v-for="(item, index) in order_info.ticketCode" :key="index">{{item}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Route from '../../utils/route.js';
	export default {
		data() {
			return {
				order_info: {}
			};
		},
		filters: {
			formatTime(timestamp) {
				var date = new Date(timestamp * 1000); //timestamp 为10位需*1000，timestamp 为13位的话不需乘1000
				var Y = date.getFullYear() + '-';
				var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
				var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
				var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
				return Y + M + D + h + m;
			},
			status(int) {
				switch (int) {
					case 1:
						return '待支付';
					case 2:
						return '受理中';
					case 3:
						return '待出票';
					case 4:
						return '已出票';
					case 5:
						return '已取票';
					case 10:
						return '订单关闭';
					case 11:
						return '已退款';
					default:
						return '已完结';
				}
			}
		},
		async onLoad(e) {
			this.order_info = await Route.order_info({
				uid: uni.getStorageSync('userInfo').uid,
				order_num: e.order_num
			})
			let time = setTimeout(() => {
				clearTimeout(time);
				uni.showToast({
					icon: 'none',
					title: '取票码支持点击预览'
				});
			}, 1000)

		},
		methods: {
			// 删除订单
			order_del() {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '是否删除该订单',
					success: async (res) => {
						if (res.confirm) {
							await Route.order_del({
								uid: uni.getStorageSync('userInfo').uid,
								order_num: that.order_info.order_num
							})
							var pages = getCurrentPages();//当前页
							var beforePage = pages[pages.length - 2];//上个页面
							beforePage.$vm.update()
							uni.navigateBack()
						} else if (res.cancel) {
						}
					}
				});
			},
			// 预览图片
			previewImg(logourl) {
				let _this = this;
				let imgsArray = [];
				imgsArray[0] = logourl
				uni.previewImage({
					current: 0,
					urls: imgsArray
				});
			},
		}
	};
</script>

<style lang="scss">
	page {
		background: #3b4144;
	}

	.movie {
		margin: 0 auto;
		border-radius: 13rpx;
		padding: 30rpx;
		margin-top: 49rpx;
		width: 630rpx;
		height: 666rpx;
		background: #fff;
		position: relative;
		background: radial-gradient(circle at left bottom, transparent 22rpx, #fff 0) top left / 346rpx 350rpx no-repeat,
			radial-gradient(circle at right bottom, transparent 22rpx, #fff 0) top right / 346rpx 350rpx no-repeat,
			radial-gradient(circle at left top, transparent 22rpx, #fff 0) bottom left / 346rpx 375rpx no-repeat,
			radial-gradient(circle at right top, transparent 22rpx, #fff 0) bottom right / 346rpx 375rpx no-repeat;

		&_status{
			position: absolute;
			z-index: 9;
			width: 150rpx;
			height: 150rpx;
			right: 0;
			bottom: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			border-radius: 50%;
			border: 1rpx dashed red;
			transform:rotate(-8deg);
			-ms-transform:rotate(-8deg); 	/* IE 9 */
			-moz-transform:rotate(-8deg); 	/* Firefox */
			-webkit-transform:rotate(-8deg); /* Safari 和 Chrome */
			-o-transform:rotate(-8deg); 	/* Opera */
			&_bor{
				width: 138rpx;
				height: 138rpx;
				border-radius: 50%;
				border: 1rpx dashed red;
				display: flex;
				align-items: center;
				justify-content: center;
				color: red;
				font-size: $uni-font-size-base;
			}
		}
		&_del {
			position: absolute;
			width: 81rpx;
			height: 81rpx;
			right: 0;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		&_info {
			height: 266rpx;
			display: flex;
			flex-direction: row;

			&_pic {
				border-radius: 13rpx;
				width: 186rpx;
				height: 266rpx;
			}

			&_text {
				width: 410rpx;
				margin-left: 25rpx;
				padding: 8rpx 0;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				font-size: $uni-font-size-base;
				color: #fff;

				&_name {
					color: #000000;
					font-size: $uni-font-size-lg;
					font-weight: 900;
				}

				&_type {
					color: #000000;
					font-weight: 300;
					font-size: $uni-font-size-base;
				}

				&_time {
					font-weight: 300;
					color: #000000;
				}

				&_address,
				&_room {
					font-weight: 300;
					color: #000000;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					overflow: hidden;
				}
			}
		}

		&_line {
			position: absolute;
			top: 350rpx;
			left: 0;
			right: 0;
			height: 6rpx;
			margin: auto;
			width: 643rpx;
			background: linear-gradient(to right, $template-line, $template-line 16rpx, transparent 16rpx, transparent);
			background-size: 10px 100%;
		}

		&_notice {
			background: #fff;
			width: 100%;
			position: absolute;
			left: 0;
			padding-bottom: 33rpx;
			border-radius: 0 0 13rpx 13rpx;
			margin-top: 100rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			&_img {
				width: 266rpx;
				height: 266rpx;
			}
		}
	}
	.movieClose{
		margin: 0 auto;
		border-radius: 13rpx;
		padding: 30rpx;
		margin-top: 49rpx;
		width: 630rpx;
		height: 450rpx;
		background: #fff;
		position: relative;
		background: radial-gradient(circle at left bottom, transparent 22rpx, #fff 0) top left / 346rpx 350rpx no-repeat,
			radial-gradient(circle at right bottom, transparent 22rpx, #fff 0) top right / 346rpx 350rpx no-repeat,
			radial-gradient(circle at left top, transparent 22rpx, #fff 0) bottom left / 346rpx 375rpx no-repeat,
			radial-gradient(circle at right top, transparent 22rpx, #fff 0) bottom right / 346rpx 375rpx no-repeat;
		
		
	}
</style>
